<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>教师列表</title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <style>
        .action-column { width: 150px; }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row mb-3">
        <div class="col-md-12">
            <h2>教师信息管理</h2>
        </div>
    </div>

    <div class="row mb-3">
        <div class="col-md-6">
            <a href="/teacher/add" class="btn btn-primary">添加教师</a>
        </div>
        <div class="col-md-6">
            <form class="form-inline float-right" action="/teacher/search" method="get">
                <div class="input-group">
                    <input type="text" name="keyword" class="form-control" placeholder="搜索教师...">
                    <div class="input-group-append">
                        <button class="btn btn-outline-secondary" type="submit">搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <table class="table table-striped table-bordered table-hover">
                <thead class="thead-dark">
                <tr>
                    <th>工号</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>职称</th>
                    <th>部门</th>
                    <th>联系电话</th>
                    <th class="action-column">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${teachers}" var="teacher">
                    <tr>
                        <td>${teacher.teacherNo}</td>
                        <td>${teacher.name}</td>
                        <td>
                            <c:choose>
                                <c:when test="${teacher.gender == 'MALE'}">男</c:when>
                                <c:when test="${teacher.gender == 'FEMALE'}">女</c:when>
                                <c:otherwise>-</c:otherwise>
                            </c:choose>
                        </td>
                        <td>${teacher.title}</td>
                        <td>${teacher.department}</td>
                        <td>${teacher.phone}</td>
                        <td>
                            <a href="/teacher/edit/${teacher.teacherId}" class="btn btn-sm btn-warning">编辑</a>
                            <a href="/teacher/delete/${teacher.teacherId}" class="btn btn-sm btn-danger"
                               onclick="return confirm('确定要删除此教师吗？')">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script src="/static/js/jquery-3.6.0.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</body>
</html>